<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
<ui:composition template="/WEB-INF/templates/maintemplate.xhtml">
	<ui:define name="content">
		<div id="cse" style="width: 100%;">Loading</div>
		<script src="http://www.google.com/jsapi" type="text/javascript"></script>
		<script type="text/javascript">
			/* <![CDATA[ */
			google.load('search', '1', {
				style : google.loader.themes.V2_DEFAULT
			});
			google
					.setOnLoadCallback(
							function() {
								var customSearchOptions = {};
								var orderByOptions = {};
								orderByOptions['keys'] = [ {
									label : 'Relevance',
									key : ''
								}, {
									label : 'Date',
									key : 'date'
								} ];
								customSearchOptions['enableOrderBy'] = true;
								customSearchOptions['orderByOptions'] = orderByOptions;
								var imageSearchOptions = {};
								imageSearchOptions['layout'] = google.search.ImageSearch.LAYOUT_POPUP;
								customSearchOptions['enableImageSearch'] = true;
								customSearchOptions['imageSearchOptions'] = imageSearchOptions;
								var customSearchControl = new google.search.CustomSearchControl(
										'000546666492082922751:y0hzrws4_tw',
										customSearchOptions);
								customSearchControl
										.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
								var options = new google.search.DrawOptions();
								options.setAutoComplete(true);
								customSearchControl
										.setAutoCompletionId('000546666492082922751:y0hzrws4_tw+qptype:1');
								customSearchControl.draw('cse', options);
								function parseParamsFromUrl() {
									var params = {};
									var parts = window.location.search
											.substr(1).split('\x26');
									for ( var i = 0; i < parts.length; i++) {
										var keyValuePair = parts[i].split('=');
										var key = decodeURIComponent(keyValuePair[0]);
										params[key] = keyValuePair[1] ? decodeURIComponent(keyValuePair[1]
												.replace(/\+/g, ' '))
												: keyValuePair[1];
									}
									return params;
								}

								var urlParams = parseParamsFromUrl();
								var queryParamName = 'q';
								if (urlParams[queryParamName]) {
									customSearchControl
											.execute(urlParams[queryParamName]);
								}
							}, true);
			/* ]]> */
		</script>
	</ui:define>
</ui:composition>
</html>
